#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e6 + 5;

int n, n2;
int a[N];
int pos[N][2];
string ans1, ans2, ans3;
bool solve(deque<int>& q, char c = 'L') {
  while (q.size()) {
    if (q.front() != q.back()) return false;
    ans2.push_back(c);
    ans2.push_back(c);
    q.pop_front(), q.pop_back();
  }
  return true;
}
bool solve(deque<int>& q1, deque<int>& q2) {
  while (q1.size() && q2.size()) {
    bool l =
        q1.front() == q2.back() || q1.size() > 1 && q1.front() == q1.back();
    bool r =
        q2.front() == q1.back() || q2.size() > 1 && q2.front() == q2.back();

    if (l) {
      ans1.push_back('L');
      int x = q1.front();
      q1.pop_front();
      if (q1.size() && q1.back() == x)
        ans3.push_back('L'), q1.pop_back();
      else
        ans3.push_back('R'), q2.pop_back();
    } else if (r) {
      ans1.push_back('R');
      int y = q2.front();
      q2.pop_front();
      if (q2.size() && q2.back() == y)
        ans3.push_back('R'), q2.pop_back();
      else
        ans3.push_back('L'), q1.pop_back();
    } else
      return false;
  }
  if (q1.size()) return solve(q1, 'L');
  if (q2.size()) return solve(q2, 'R');
  return true;
}
bool check(int x) {
  int l = pos[x][0], r = pos[x][1];
  ans1.clear(), ans2.clear(), ans3.clear();
  deque<int> q1, q2;
  if (l == 1) {
    ans1.push_back('L');
    ans3.push_back('L');
    rep(i, l + 1, r - 1) q1.push_back(a[i]);
    per(i, n2, r + 1) q2.push_back(a[i]);
  } else {
    ans1.push_back('R');
    ans3.push_back('L');
    rep(i, 1, l - 1) q1.push_back(a[i]);
    per(i, n2 - 1, l + 1) q2.push_back(a[i]);
  }
  return solve(q1, q2);
}
bool solve() {
  cin >> n;
  n2 = n * 2;
  rep(i, 1, n2) cin >> a[i];
  rep(i, 1, n) pos[i][0] = pos[i][1] = 0;
  rep(i, 1, n2) {
    int x = a[i];
    pos[x][0] = i;
    swap(pos[x][0], pos[x][1]);
  }
  int h = a[1], t = a[n2];
  if (h == t) {
    deque<int> q;
    rep(i, 1, n2) q.push_back(a[i]);
    ans1.clear(), ans2.clear(), ans3.clear();
    return solve(q);
  } else {
    return check(h) || check(t);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    if (solve()) {
      reverse(ans3.begin(), ans3.end());
      cout << ans1 << ans2 << ans3 << endl;
    } else
      cout << -1 << endl;
  }
  return 0;
}